<template>
	<view>
		<my-animation :share="share" :height="height" @display="display">
			<template v-slot:spOne>
				<!-- 1，头部标题 -->
				<view class="top">
					<view></view>
					<view class="title">
						<text>预约时间</text>
					</view>
					<view class="close" @click="display">
						<text>×</text>
					</view>
				</view>
				<!-- 2，主要内容 -->
				<view class="con">
					<view class="con-left">
						<view @click="changeActive(item,index)" :class="[activeId == index + 1 ? 'activeDay':'' ]"
							class="con-left-day" v-for="(item,index) in dayList" :key="index">
							<text>{{item}}</text>
						</view>
					</view>
					<view class="con-right">
						<scroll-view class="con-right-scroll" scroll-y="true">
							<block v-for="(item,index) in hightList">
								<view @click="getTime(item)" class="con-right-hight"><text>{{item}}</text></view>
							</block>
						</scroll-view>
					</view>
				</view>
			</template>
		</my-animation>
	</view>
</template>

<script>
	import myAnimation from '@/components/common/my-animation/my-animation.vue'

	export default {
		props: {
			share: {
				type: Boolean,
				default: false
			}
		},
		components: {
			myAnimation
		},
		data() {
			return {
				height: '800',
				dayList: [],
				activeId: 1,
				timeDay: '',
				hightList: [
					'08:00', '09:00', '10:00',
					'11:00', '12:00', '13:00',
					'14:00', '15:00', '16:00',
					'17:00', '18:00', '19:00',
					'20:00', '21:00', '22:00',
				]
			}
		},
		methods: {
			display() {
				this.$emit('display')
			},
			getDayStr(AddDayCount) {
				//获取今天日期
				var dd = new Date();
				dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 
				var y = dd.getFullYear();
				var m = dd.getMonth() + 1; //获取当前月份的日期 
				var d = dd.getDate();

				if (m >= 1 && m <= 9) {
					m = "0" + m;
				}
				if (d >= 0 && d <= 9) {
					d = "0" + d;
				}
				var date = y + "-" + m + "-" + d;
				return date
			},
			getDayList() {
				var jt = this.getDayStr(0)
				this.timeDay = jt
				this.dayList.push(jt)
				this.dayList.push(this.getDayStr(1))
				this.dayList.push(this.getDayStr(2))
				this.dayList.push(this.getDayStr(3))
				this.dayList.push(this.getDayStr(4))
			},
			changeActive(item, index) {
				this.activeId = index + 1
				this.timeDay = item
			},
			getTime(item) {
				var time = this.timeDay + ' ' + item + ':00'
				this.$emit('getTime', time)
			}
		},
		created() {
			//今日为 this.getDayStr(0)
			this.getDayList()
		}
	}
</script>

<style lang="scss" scoped>
	.activeDay {
		background-color: #fff;
	}

	.top {
		width: 100%;
		height: 100rpx;
		display: flex;


		view {
			//width: 33.33%;
			flex: 1;
		}

		.title {
			text-align: center;
			line-height: 100rpx;
			font-size: 32rpx;
		}

		.close {
			text-align: right;
			line-height: 100rpx;
			font-size: 45rpx;
			border-radius: 50%;

			text {
				margin-right: 30rpx;
				color: rgba(128, 128, 128, 1);
			}
		}
	}

	.con {
		display: flex;
		width: 100%;

		.con-left {
			width: 40%;
			background-color: #eee;
			height: 700rpx;

			.con-left-day {
				width: 100%;
				height: 100rpx;
				line-height: 100rpx;
				text-align: center;
				font-size: 32rpx;
			}
		}

		.con-right {
			width: 60%;

			.con-right-scroll {
				height: 599rpx;
			}

			.con-right-hight {
				width: 100%;
				height: 80rpx;
				text-align: center;
				font-size: 28rpx;
				line-height: 80rpx;

				&:active {
					background-color: #dbdbdb;
				}
			}
		}
	}
</style>
